﻿/*!
* jQuery tree plugin: 
* 
* version 0.1 2011-03-10
* Requires jQuery v1.4.2 or later
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Kim Seoung Min
* Company : Kongyoung DB
*/

(function ($) {
    $.fn.supercalculator = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.tooltip');
        }
    };

    //var AutocompleteisRun = false;

    var methods = {
        init: function () {
            var Supercal = $(this);
            var _Sum1 = "";
            var _Sum2 = "";
            var _Cal = "";
            $(this).click(function (e) {

                $('.AutoLevelDiv').remove();
                $(document.body).append("<div class='AutoLevelDiv'></div>");
                $('.AutoLevelDiv').css("top", Supercal.offset().top + Supercal.outerHeight());
                $('.AutoLevelDiv').css("left", Supercal.offset().left);
                $('.AutoLevelDiv').css("width", Supercal.outerWidth());
                $('.AutoLevelDiv').append("<table id='Tcalculator' />");
                $('.AutoLevelDiv').append("<tr />");
                $('.AutoLevelDiv').append("<td />");
                $('.AutoLevelDiv').append("<input type='button' id='btn_01' class='ui-widget-content' style='width:30px;' value='1' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' id='btn_02' class='ui-widget-content' style='width:30px;' value='2' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='3' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='-' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='1/x' />&nbsp;");
                $('.AutoLevelDiv').append("</td >");
                $('.AutoLevelDiv').append("</tr >");
                $('.AutoLevelDiv').append("<tr />");
                $('.AutoLevelDiv').append("<td />");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='0' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='+/-' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' class='ui-widget-content' style='width:30px;' value='.' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' id='btn_09' class='ui-widget-content' style='width:30px;' value='+' />&nbsp;");
                $('.AutoLevelDiv').append("<input type='button' id='btn_10' class='ui-widget-content' style='width:30px;' value='=' />&nbsp;");
                $('.AutoLevelDiv').append("</td >");
                $('.AutoLevelDiv').append("</tr >");
                $('.AutoLevelDiv').append("</table >");

                $('#btn_01').click(function (e) {
                    _Sum1 += 1;
                    Supercal.val(_Sum1);
                });

                $('#btn_02').click(function (e) {
                    _Sum1 += 2;
                    Supercal.val(_Sum1);
                });

                $('#btn_09').click(function (e) {
                    _Cal = "+";
                    _Sum2 = _Sum1;
                    _Sum1 = '';
                });

                $('#btn_10').click(function (e) {
                    Supercal.val(eval(parseInt(_Sum1) + _Cal + parseInt(_Sum2)));
                });



                //$('.AutoLevelDiv').append("<input type='button' class='AutoLevelBtnClose ui-widget-content' value='닫기' />");
                //$('.AutoLevelBtnClose').click(function (e) {
                //    $('.AutoLevelDiv').remove();
                //});

            })

        },

        WhoIs: function () {
        }
    }
})(jQuery);


